import socket

sk = socket.socket()

# 绑定监听地址及IP
sk.bind(('127.0.0.1', 6666))

# max listener
sk.listen(5)

# listen info from client
print('Server is starting listening')
while True:
  conn, address = sk.accept()

  while True:
    ret_butes = conn.recv(1024)
    ret_str = str(ret_butes, encoding='utf-8')
    if ret_str == 'q':
      break
    elif ret_str == 'cd':
      conn.sendall(bytes("""
  ===Menu===
                         1. search
                         2. active
                         3. subscription
                         4. preview
                         ====answer No. to choose===
""", 'utf-8'))